<?php

ob_start();
session_start();

//$_SESSION['list_news_list'] = 1;
/* error_reporting(E_ALL);
ini_set('display_errors', 1); */
require("libraries/Mobile_Detect.php");
//Check and set session mobile
if(!isset($_SESSION['mobile'])){
	$detect = new Mobile_Detect;
	if ( $detect->isMobile() ) {
	 	if ( $detect->isMobile() ) {
 			$_SESSION['mobile']=1;
		}
		// Any tablet device.
		if( $detect->isTablet() ){
		 	$_SESSION['mobile']=2;
		}
	}else{
		$_SESSION['mobile']=0;	
	}
}

//$_SESSION['mobile']=0;	

require("libraries/db_record2.php");
require("libraries/config.php");
require("libraries/function.php");
require("libraries/cache.php");

require("libraries/modules/user/user.php");
require("libraries/bbcode.php");
require("helpers/number.php");

require("no-cache/no-cache.php");
require("libraries/simple_html_dom.php");
require("libraries/snoopy.php");

require("libraries/modules/common/common.php");



require("libraries/modules/manga/f1.php");
require("libraries/modules/manga/f2.php");
require("libraries/modules/manga/render.php");
require("libraries/modules/manga/mobile_render.php");
require("libraries/modules/common/render.php");
//Video , blog file
require("libraries/modules/blog/video.php");
require("libraries/modules/blog/video_render.php");
//Blog
require("libraries/modules/blog/blog.php");
require("libraries/modules/blog/blog_render.php");
//TruyenCV
require("libraries/modules/convert/truyencv.php");

//Truyen
require("libraries/modules/truyen/f1.php");
require("libraries/modules/truyen/render.php");


require("libraries/pagination.php");
if(!isset($_SESSION['user'])){
check_user_cookie();
}else{
//Check user update user information-------
check_user_name();
}


												
													
if(isset($_GET['module']))
{	$mod=$_GET['module'];
	switch($mod)
		{
		case "convert":require("controllers/convert/controller.php");
			break;
		case "truyen":require("controllers/truyen/controller.php");
			break;	
		case "anime":require("controllers/anime/controller.php");
			break;
		case "video":require("controllers/video/controller.php");
			break;
		case "blog":require("controllers/blog/controller.php");
			break;	
		
		case "user":require("controllers/user/controller.php");
			break;
		case "manage":require("controllers/manage/controller.php");
			break;
		
		case "comment":require("controllers/comment/controller.php");
			break;
		case 'ajax': require('controllers/ajax/controller.php');
			break;
		}
}
else
if(isset($_POST['module']))
{	$mod=$_POST['module'];
	switch($mod)
	{
	case "anime":require("controllers/anime/controller.php");
		break;	
	case "convert":require("controllers/convert/controller.php");
		break;
	case "truyen":require("controllers/truyen/controller.php");
		break;	
	case "manage":require("controllers/manage/controller.php");
		break;
	case "video":require("controllers/video/controller.php");
		break;
	case "blog":require("controllers/blog/controller.php");
		break;				
	case "comment":require("controllers/comment/controller.php");
		break;
	case "user":
	require("controllers/user/controller.php");
		break;
	case 'ajax': require('controllers/ajax/controller.php');
		break;
					
	}
}
else
{	
require("controllers/anime/list_home.php");
}


if($_GET['act'] != 'ajax'){
loadview("template/footer");
}

ob_end_flush();
?>
